pub fn convert_base(num_str: &str, to_base: u32) -> String {
    let num_vec: Vec<&str> = num_str.split('(').collect();
    let num = num_vec[0];
    let base = num_vec[1].split(')').collect::<Vec<&str>>()[0]
        .parse::<u32>()
        .unwrap();
    let decimal_num = u32::from_str_radix(num, base)
        .map_err(|_| format!("Invalid!"))
        .unwrap();
    to_base_string(decimal_num, to_base)
}

fn to_base_string(mut num: u32, base: u32) -> String {
    if num == 0 {
        return "0".to_string();
    }

    let mut result = String::new();
    while num > 0 {
        let remainder = num % base;
        let digit = std::char::from_digit(remainder, base).unwrap();
        result.insert(0, digit);
        num /= base;
    }
    result
}
